package kaizone.haining.chaobohui.json;

import org.json.JSONObject;

public class NewsItem extends Item{
    
    public static final String CATEGORYID = "categoryId";
    public static final String CATEGORYNAME = "categoryName";
    public static final String CONTENT = "content";
    public static final String DISPLAYORDER = "displayOrder";
    public static final String GMTPUBLISH = "gmtPublish";
    public static final String ISTOP = "isTop";
    public static final String SOURCE = "source";
    public static final String STATUS = "status";
    public static final String SUMMARY = "summary";
    public static final String TITLE = "title";
    public static final String CONTENTURL = "contentUrl";
    
    
    public static final String FLAG_ISTOP_Y = "Y";
    public static final String FLAG_ISTOP_N = "N";
    
    private int categoryId;
    private String categoryName;
    private String content;
    private String displayOrder;
    private String gmtPublish;
    private String isTop;
    private String source;
    private String status;
    private String summary;
    private String title;
    private String contentUrl;
    
    public int getCategoryId() {
        return categoryId;
    }
    public void setCategoryId(int categoryId) {
        this.categoryId = categoryId;
    }
    public String getCategoryName() {
        return categoryName;
    }
    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getDisplayOrder() {
        return displayOrder;
    }
    public void setDisplayOrder(String displayOrder) {
        this.displayOrder = displayOrder;
    }
    public String getGmtPublish() {
        return gmtPublish;
    }
    public void setGmtPublish(String gmtPublish) {
        this.gmtPublish = gmtPublish;
    }
    public String getIsTop() {
        return isTop;
    }
    public void setIsTop(String isTop) {
        this.isTop = isTop;
    }
    public String getSource() {
        return source;
    }
    public void setSource(String source) {
        this.source = source;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    public String getSummary() {
        return summary;
    }
    public void setSummary(String summary) {
        this.summary = summary;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getContentUrl() {
		return contentUrl;
	}
	public void setContentUrl(String contentUrl) {
		this.contentUrl = contentUrl;
	}
	
	public static NewsItem parse(JSONObject jsonObject){
        NewsItem newsItem = new NewsItem();
        
        Item item = Item.parse(jsonObject);
        newsItem.setItem(item);
        
        newsItem.setCategoryId(jsonObject.optInt(CATEGORYID));
        newsItem.setCategoryName(jsonObject.optString(CATEGORYNAME));
        newsItem.setContent(jsonObject.optString(CONTENT));
        newsItem.setContentUrl(jsonObject.optString(CONTENTURL));
        newsItem.setDisplayOrder(jsonObject.optString(DISPLAYORDER));
        newsItem.setGmtPublish(jsonObject.optString(GMTPUBLISH));
        newsItem.setIsTop(jsonObject.optString(ISTOP));
        newsItem.setSource(jsonObject.optString(SOURCE));
        newsItem.setStatus(jsonObject.optString(STATUS));
        newsItem.setSummary(jsonObject.optString(SUMMARY)); 
        newsItem.setTitle(jsonObject.optString(TITLE));
        
        return newsItem;
    }

}
